package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/number-of-laser-beams-in-a-bank/?envType=daily-question&envId=2025-10-27
 * @create 2025/10/27 11:25
 * @since JDK17
 */

public class Solution69 {
    public int numberOfBeams(String[] bank) {
        int ans = 0, preCnt = 0, cnt = 0;
        for (var row : bank) {
            cnt = 0;
            for (var x : row.toCharArray()) {
                cnt += x - '0';
            }
            if (cnt > 0) {
                ans += preCnt * cnt;
                preCnt = cnt;
            }
        }

        return ans;
    }
}
